package com.Test;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

public class Test31 {
    public static void main(String[] args) {
        // 获取今天的日期
        LocalDate today = LocalDate.now();

        // 获取前两天的日期
        LocalDate twoDaysAgo = today.minusDays(2);

        // 定义日期格式
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");

        // 转换为字符串
        String todayString = today.format(formatter);
        String yesterdayString = today.minusDays(1).format(formatter);
        String twoDaysAgoString = twoDaysAgo.format(formatter);

        // 打印结果
        System.out.println("今天的日期: " + todayString);
        System.out.println("前一天的日期: " + yesterdayString);
        System.out.println("前两天的日期: " + twoDaysAgoString);
    }
}
